ARROW-12165: [Rust] inline append functions of builders#9860
Conversation
nevi-me
left a comment
There was a problem hiding this comment.
This makes sense, there's lots of appending going on here 😵
|
@ritchie46 did you have some perf results on this? |
There was a problem hiding this comment.
This seems a large function to inline? Maybe we need to be conservative here and not mark it as inline
There was a problem hiding this comment.
Ok, I will remove that one.
There are quite some functions, but for met the most important one is the primitive builder. Running this benchmark: fn create_primitive_array(n: usize) -> PrimitiveArray<Int64Type> {
let mut builder = PrimitiveBuilder::new(n);
for i in 0..n {
builder.append_value(i as i64).unwrap();
}
builder.finish()
}
fn add_benchmark(c: &mut Criterion) {
c.bench_function("512", |b| b.iter(|| create_primitive_array(512)));
c.bench_function("4096", |b| b.iter(|| create_primitive_array(4096)));
}Gave the following improvement: PrimitiveBuilderStringBuilderFor a |
fcd2dee to
1cb93ee
Compare
Is there a reason not to remove this? Backwards incompatibility changes are already happened, so maybe we can remove this? |
|
@ritchie46 quite nice micro benchmark results 👍
I don't think there is any reason. I tried to do it some time ago, but it requires a lot of work as it is used in quite some code as you can imagine. |
Codecov Report
@@ Coverage Diff @@
## master #9860 +/- ##
==========================================
- Coverage 82.61% 82.60% -0.01%
==========================================
Files 254 255 +1
Lines 59583 59588 +5
==========================================
Hits 49225 49225
- Misses 10358 10363 +5
Continue to review full report at Codecov.
|
Yeah I agree it would make the API easier to work with if the builders didn't return |
alamb
left a comment
There was a problem hiding this comment.
Thanks @ritchie46 -- this looks great to me
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #9860 +/- ##
==========================================
- Coverage 82.61% 82.60% -0.01%
==========================================
Files 254 255 +1
Lines 59583 59588 +5
==========================================
Hits 49225 49225
- Misses 10358 10363 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
The
appendfunctions in theBuilderstructs are often used in "hot" code. This PR tags them with#[inline], making it possible to inline the function calls across crate boundaries.